//
//  YMPlayerFinishedView.m
//  SmartCar
//
//  Created by y s on 2022/12/25.
//

#import "YMPlayerFinishedView.h"

@interface YMPlayerFinishedView ()

@property (nonatomic,strong)UIImageView *backiView;
@property (nonatomic,strong)UILabel  *replayVLabel;
@property (nonatomic,strong)UIButton *replayVBtn;

@end

@implementation YMPlayerFinishedView

// GCD单例
- (instancetype)init{
    self = [super init];
    if(self){
        [self setUI];
        [self layOut];
    }
    return self;
}

- (void)setUI{
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
    _replayVLabel = [SThemeUtil label:@"重播" color:0x999999 fontSize:12];
    
    [self addSubview:self.backiView];
    [self.backiView addSubview:self.replayVBtn];
    [self.backiView addSubview:_replayVLabel];
}

- (void)layOut{
    [_backiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    [_replayVBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.centerX.mas_equalTo(0);
    }];
    [_replayVLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_replayVBtn.mas_bottom).mas_offset([SFitUtil fit:6]);
        make.centerX.equalTo(_replayVBtn);
    }];
}

- (void)setBackImage:(NSString *)imageName
{
    [self.backiView sd_setImageWithURL:[NSURL URLWithString:imageName] placeholderImage:[[UIImage alloc] init]];
}


- (UIImageView *)backiView{
    if(!_backiView){
        _backiView = [[UIImageView alloc] init];
        _backiView.userInteractionEnabled = YES;
    }
    return _backiView;
}
- (UIButton *)replayVBtn{
    if (!_replayVBtn) {
        _replayVBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_replayVBtn setImage:[UIImage imageNamed:@"player_replay_icon"] forState:UIControlStateNormal];
        __weak typeof(self) weakSelf=self;
        [_replayVBtn g_clickBlock:^(id sender) {
            weakSelf.hidden = YES;
            if(weakSelf.replayBlock){
                weakSelf.replayBlock();
            }
        }];
    }
    return _replayVBtn;
}



@end
